﻿select Customer.Email, Customer.CreatedOnUtc, GenericAttribute.[Key], GenericAttribute.Value from Customer inner join GenericAttribute on Customer.Id = GenericAttribute.EntityId where Customer.CreatedOnUtc > '2014-12-17' AND Customer.Email is not null and Customer.Deleted = 0 And (GenericAttribute.[Key] like '%Name' or GenericAttribute.[Key] = 'ZipPostalCode')
select Customer.Email, Customer.CreatedOnUtc, GenericAttribute.[Key], GenericAttribute.Value from Customer inner join GenericAttribute on Customer.Id = GenericAttribute.EntityId where Customer.Email is not null and Customer.Deleted = 0 And (GenericAttribute.[Key] like '%Name' or GenericAttribute.[Key] = 'ZipPostalCode') and Region_Id = 2

select Customer.Email, Customer.CreatedOnUtc, GenericAttribute.[Key], GenericAttribute.Value, addr.Address1, addr.Address2, addr.City, addr.StateProvinceId, addr.ZipPostalCode from Customer inner join [Address] addr on [Customer].ShippingAddress_Id = addr.Id inner join GenericAttribute on Customer.Id = GenericAttribute.EntityId where Customer.CreatedOnUtc > '2012-01-01' AND Customer.Email is not null and Customer.Deleted = 0 and (GenericAttribute.[Key] like '%Name' or GenericAttribute.[Key] = 'Company')

select DISTINCT c.Email, GenericAttribute.Value, GenericAttribute.[Key] from Shipment s inner join [Order] o on s.OrderId = o.Id inner join Customer c on c.Id = o.CustomerId inner join GenericAttribute on Customer.Id = GenericAttribute.EntityId where Attributes is not null and (Attributes & 1024) != 0

select p.Id, p.CreatedOnUtc, a.FirstName, a.LastName, a.CellPhoneNumber, a.PhoneNumber, s.TrackingNumber, s.Comment from LogisticsPackage p inner join LogisticsLocation l on p.DeliveryLocationId = l.Id inner join [Address] a on a.Id = l.AddressId inner join Shipment s on p.ShipmentId = s.Id where (p.ApplicatorId = 94732 or p.ApplicatorId = 52877) and (p.Status = 81 or p.Status = 71)

select * from Customer where Region_Id = 2


select Customer.Email, Customer.CreatedOnUtc, GenericAttribute.[Key], GenericAttribute.Value from Customer inner join GenericAttribute on Customer.Id = GenericAttribute.EntityId where Customer.CreatedOnUtc > '2014-5-28' AND Customer.Email is not null and Customer.Deleted = 0 And (GenericAttribute.[Key] = 'ZipPostalCode' and (GenericAttribute.[Value] like 'T5%' or GenericAttribute.[Value] like 'T6%' or GenericAttribute.[Value] like 'T8%'))

select DISTINCT o.Id, o.CreatedOnUtc, o.OrderTotal from Shipment s inner join [Order] o on s.OrderId = o.Id inner join Customer c on c.Id = o.CustomerId where s.Attributes is not null and (s.Attributes & 1024) != 0